<template>
	<!-- #ifndef MP-WEIXIN -->
	<view class="f wt">
	<!-- #endif -->
	<!-- #ifdef MP-WEIXIN -->
	<view class="f wt" @click="$emit('click')">
	<!-- #endif -->
		<view class="f1" :style="{'text-align':ta}" v-if="modelValue">{{modelValue}}</view>
		<view class="f1 c9" :style="{'text-align':ta}" v-else>{{placeholder}}</view>
		<u-icon v-if="showArrow" name="arrow-down" color="#999" />
	</view>
</template>

<script lang="ts">
import Emitter from 'uview-plus/libs/util/emitter'

export default {
	mixins: [Emitter],
	props: {
		modelValue: {
			type: [String, Number],
			default: ''
		},
		placeholder: {
			type: [String, Number],
			default: ''
		},
		showArrow: {
			type: Boolean,
			default: true
		},
		ta: {
			type: String,
			default: 'left'
		}
	},
	watch: {
		modelValue(newVal, oldVal){
			setTimeout(() => {
				// 将当前的值发送到 u-form-item 进行校验
				this.dispatch('u-form-item', 'onFieldChange', newVal)
			}, 40)
		}
	}
}
</script>